<?php
session_start();

$frist=!count($_POST);

?>


<html>
    <head>
        <meta charset="UTF-8">
        <title>用户注册表</title>
        <style>
            .zh{
                text-align:center;
                border-radius:20px;
                width:500px;
                height:500px;
                position:absolute;
                left:50%;
                top:50%;
                transform:translate(-50%,-50%);
                border-style:solid;
                 background-repeat: no-repeat;
            }
            body{
                 width:3010px;
                height:2010px;
                 background-repeat: no-repeat;
                 background-image: url(2.jpg);
               background-size: 100%;
            /*transform: rotate(90deg);*/ 
            }
            .a{
               
                height: 100px;
                
            }
            .b{
               position: absolute;
               transform:translate(400%,50%);
            }
            .c{
                 position: absolute;
                transform:translate(700%,-40%);
            }
        </style>
    </head>
    <body >
        <?php
        if($frist){
            
        
        ?>
        
        <div class="zh">
            <form action="login1.php" method="post"
                  enctype="multipart/form-data">
                <h3>用户登录</h3>
                <div>登录账号：<input type="text"  name="username"></div>
                <br/>
                <div>登录密码：<input type="password" name="password"></div>
                <br/>
               
               
               
                <br/>
                <div class="a" >
                    <div class="b"><input type="submit" value="确定"/></div>
                    <br/>
                    <div class="c"> <input type="reset" value="取消"/></div>
                 </div>
               
            </form>
        </div>
         <?php
        }else{
            header("content-type:html;charset=utf-8");
            $hostname="127.0.0.1";
            $username="root";
            $password="123456";
            $database="tpsc";
            $link=mysqli_connect($hostname, $username,
            $password, $database);
            mysqli_set_charset($link, "utf-8");
            $username = $_POST["username"];
            $password = $_POST["password"];
//            $mycode = $_POST["mycode"];
            $sql = "select *from user where username='$username'";
            $res = mysqli_query($link,$sql);
            $arr = mysqli_fetch_assoc($res);
//            if($mycode != $_SESSION['captcha']){
//                echo "<script>alert('验证码错误');window.location.href='login.php'</script>";
//            }
            echo '$password='.$password."====";
            echo '$arr='.$arr."++++";
            echo 'arr[passwdor]'.$arr["passwd"];
           
//           
            
            
            
            if($arr){
               if($password == $arr["passwd"]){
                   echo "<script>alert('登录成功');window.location.href='index.php'</script>";
               }else{
                   echo "<script>alert('密码错误');window.location.href='login1.php'</script>";
               }
            }else{
                echo "<script>alert('账号错误');window.location.href='login1.php'</script>";
            }
        }
        
        ?>
            
    </body>
</html>

